class ProductUserpostratio {
  String? id;
  String? workshopId;
  String? workshopName;
  String? factoryId;
  String? factoryName;
  String? stationId;
  String? stationName;
  String? postId;
  String? postName;
  String? postratio;
  String? remark;
  String? active;
  String? createUid;
  String? createUidName;
  String? createDate;
  String? writeUid;
  String? writeUidName;
  String? writeDate;

  ProductUserpostratio({
    this.id,
    this.workshopId,
    this.workshopName,
    this.factoryId,
    this.factoryName,
    this.stationId,
    this.stationName,
    this.postId,
    this.postName,
    this.postratio,
    this.remark,
    this.active,
    this.createUid,
    this.createUidName,
    this.createDate,
    this.writeUid,
    this.writeUidName,
    this.writeDate,
  });

  ProductUserpostratio copyWith({
    String? id,
    String? workshopId,
    String? factoryId,
    String? stationId,
    String? postId,
    String? postratio,
    String? remark,
    String? active,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductUserpostratio(
      id: id ?? this.id,
      workshopId: workshopId ?? this.workshopId,
      factoryId: factoryId ?? this.factoryId,
      stationId: stationId ?? this.stationId,
      postId: postId ?? this.postId,
      postratio: postratio ?? this.postratio,
      remark: remark ?? this.remark,
      active: active ?? this.active,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductUserpostratio{
      id: id,
      workshopId: workshopId,
      factoryId: factoryId,
      stationId: stationId,
      postId: postId,
      postratio: postratio,
      remark: remark,
      active: active,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is ProductUserpostratio &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          workshopId == other.workshopId &&
          factoryId == other.factoryId &&
          stationId == other.stationId &&
          postId == other.postId &&
          postratio == other.postratio &&
          remark == other.remark &&
          active == other.active &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory ProductUserpostratio.fromMap(Map<String, dynamic> map) {
    return new ProductUserpostratio(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      workshopId: map['workshop_id'] != false
          ? map['workshop_id'][0].toString() as String?
          : "",
      workshopName: map['workshop_id'] != false
          ? map['workshop_id'][1].toString() as String?
          : "",
      factoryId: map['factory_id'] != false
          ? map['factory_id'][0].toString() as String?
          : "",
      factoryName: map['factory_id'] != false
          ? map['factory_id'][1].toString() as String?
          : "",
      stationId: map['station_id'] != false
          ? map['station_id'][0].toString() as String?
          : "",
      stationName: map['station_id'] != false
          ? map['station_id'][1].toString() as String?
          : "",
      postId: map['post_id'] != false
          ? map['post_id'][0].toString() as String?
          : "",
      postName: map['post_id'] != false
          ? map['post_id'][1].toString() as String?
          : "",
      postratio: map['postratio'] != false
          ? map['postratio'].toString() as String?
          : "",
      // postratio: map['postratio'] != false ? map['postratio'] : null,
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      active: map['active'] != false ? map['active'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'][0].toString() as String?
          : "",
      createUidName: map['create_uid'] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'][0].toString() as String?
          : "",
      writeUidName: map['write_uid'] != false
          ? map['write_uid'][1].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshopId': this.workshopId,
      'factoryId': this.factoryId,
      'stationId': this.stationId,
      'postId': this.postId,
      'postratio': this.postratio,
      'remark': this.remark,
      'active': this.active,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      ['active', '!=', null],
      if (this.postName != null && this.postName != '')
        ['post_id', 'like', '%${this.postName}%'],
      if (this.factoryId != null && this.factoryId != '')
        ['factory_id', '=', int.parse(this.factoryId!)],
      if (this.workshopId != null && this.workshopId != '')
        ['workshop_id', '=', int.parse(this.workshopId!)],
      if (this.stationId != null && this.stationId != '')
        ['station_id', '=', int.parse(this.stationId!)],
      if (this.postId != null && this.postId != '')
        ['post_id', '=', int.parse(this.postId!)],
    ] as List;
    // if (list.length == 0) {
    //   list.add(['id', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshop_id': int.parse(this.workshopId!),
      'factory_id': int.parse(this.factoryId!),
      'station_id': int.parse(this.stationId!),
      'post_id': int.parse(this.postId!),
      'postratio': this.postratio,
      // if (postratio is int) 'postratio': int.parse(postratio!),
      // if (postratio is double) 'postratio': double.parse(postratio!),
      'remark': this.remark,
      // if (active != null && active != "") 'active': int.parse(this.active!),
      'active': this.active,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
